﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace docent
{
    public class FlowFactory
    {
        public static FlowFactory Instance { get; private set; }
        static FlowFactory()
        {
            Instance = new FlowFactory();
        }
        private FlowFactory() { }

        public Flow Create(string docType)
        {
            Flow flow = new Flow() { ID = 1, Name = "Default" };

            FlowAction write = new FlowAction() { ID = 1, Name = "开始写", Executor="" };
            FlowAction writeComplete = new FlowAction() { ID = 2, Name = "写毕", Executor = "" };
            FlowAction review = new FlowAction() { ID = 3, Name = "开始审", Executor = "" };
            FlowAction reviewComplete = new FlowAction() { ID = 4, Name = "审毕", Executor = "" };
            FlowAction publish = new FlowAction() { ID = 5, Name = "发布", Executor = "" };

            FlowAction view = new FlowAction() { ID = 10, Name = "查看", };

            FlowNode nodeBeWritten = new FlowNode() { ID = 1, Name = "还没写", State = FlowState.BeWritten }; flow.Add(nodeBeWritten);
            FlowNode nodeWriting = new FlowNode() { ID = 2, Name = "正在写", State = FlowState.Writing }; flow.Add(nodeWriting);
            FlowNode nodeWritten = new FlowNode() { ID = 3, Name = "已写完", State = FlowState.Written }; flow.Add(nodeWritten);
            FlowNode nodeBeReviewed = new FlowNode() { ID = 4, Name = "还没审", State = FlowState.BeReviewed }; flow.Add(nodeBeReviewed);
            FlowNode nodeReviewing = new FlowNode() { ID = 5, Name = "正在审", State = FlowState.Reviewing }; flow.Add(nodeReviewing);
            FlowNode nodeReviewed = new FlowNode() { ID = 6, Name = "已审完", State = FlowState.Reviewed }; flow.Add(nodeReviewed);
            FlowNode nodePublished = new FlowNode() { ID = 7, Name = "已发布", State = FlowState.Published }; flow.Add(nodePublished);

            nodeBeWritten.AddAction(view, write);
            nodeWriting.AddAction(view, writeComplete);
            nodeWritten.AddAction(view, review);
            nodeBeReviewed.AddAction(view, review);
            nodeReviewing.AddAction(view, reviewComplete);
            nodeReviewed.AddAction(view, publish);

            return flow;
        }
    }
}
